package bairui.international.weixin.portal.miniapp.controller.ticket.offset;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.querydsl.QSort;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_ElectronicTicket;
import bairui.international.model.status.State_ElectronicTicket;
import bairui.international.service.Service_ElectronicTicket;

/**
 *
 * 可用列表
 *
 * @generated
 * 
 * @see STest_C_Ticket_Offset_UsePage_Get 测试
 *
 */
@Controller
public class C_Ticket_Offset_UsePage_Get
 extends SC_Ticket_Offset_UsePage_Get 
{
	
	@Autowired private Service_ElectronicTicket service_ElectronicTicket;
	
	/**
	 * Get请求
	 */
	@Action(Get.class)
	@GetMapping(Get.RequestMappingValue)
	public @FomatOutput @ResponseBody Object get(
		ModelMap map, HttpServletRequest request,
		@RequestParam Integer startPage,
		@RequestParam String skey
	) throws Exception {
		Page<TB_ElectronicTicket> page = service_ElectronicTicket.page(
					it->it.takor.skey.eq(skey)
						.and(it.state.eq(State_ElectronicTicket.Taked)),
					PageRequest.of(startPage, 5000),
					it->new QSort(it.electronicTicketOrder.expiryDate.desc(), it.electronicTicketOrder.price.desc())
				);
		return page.map(it->new Output(it, skey));
	}
	

}
